package xiegd.study.localTime;

import java.text.SimpleDateFormat;
import java.time.format.DateTimeFormatter;

/**
 * @Author: xieguangda
 * @Description:
 * @Date: 2023/3/21 15:36
 */
public class Test {
    // 一般我们使用SimpleDateFormat的时候会把它定义为一个静态变量，避免频繁创建它的对象实例
    public static SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");

    private static  DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");

    private static SimpleDateFormat getSimpleDateFormat(String pattern) {
        return new SimpleDateFormat(pattern);
    }
    public static void main(String[] args) {

        String[] dateStringArray = new String[] { "2020-09-10", "2020-09-11", "2020-09-12", "2020-09-13", "2020-09-14"};

        MyThread[] myThreads = new MyThread[5];

        // 创建线程
        for (int i = 0; i < 5; i++) {
//            myThreads[i] = new MyThread(simpleDateFormat, dateStringArray[i]);
            myThreads[i] = new MyThread(dtf, dateStringArray[i]);
        }


        // 启动线程
        for (int i = 0; i < 5; i++) {
            myThreads[i].start();
        }
    }
}

